import java.io.*;

	/**
	* @author Joshua Oberle.
	*/

public class FakeClient{

	/**
	* This runs client from command line given a tarball, ip, and port.
	*
	* This will only work on linux. It is provided simply for convenience.
	*
	* @param args[0] The name of the tarball to feed to the server.
	* @param args[1] The IP of the server.
	* @param args[2] The port to connect with.
	*/

	public static void main(String[] args){
		String s = null;
		String[] cmdarray = new String[5];
		try{
			String[] cmd = {"/bin/sh","-c","tar --to-stdout -zxf " + args[0] + " | java -cp .:maxmindgeoip.jar LogClient " + args[1] + " " + args[2]};
			Process p = Runtime.getRuntime().exec(cmd);
			BufferedReader stdInput = new BufferedReader(new InputStreamReader(p.getInputStream()));
			BufferedReader stdError = new BufferedReader(new InputStreamReader(p.getErrorStream()));
			
		        while ((s = stdInput.readLine()) != null) {
                		System.out.println(s);
            		}

	            	while ((s = stdError.readLine()) != null) {
                		System.out.println(s);
            		}
		}catch(Exception e){
			e.printStackTrace();
		}
	}//main(String[])
}//class LogFileReader